<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

/*Route::get('/', function () {
    return view('welcome');
});*/


Route::get('/home', 'HomeController@index')->name('home');
Route::get('/', 'ThreadsController@index');

/*Route::get('/threads','ThreadsController@index')->name('threads.index');
Route::post('/threads','ThreadsController@store');
Route::get('/threads/{thread}','ThreadsController@show');*/


/*Route::get('/threads', 'threadsController@index')->name('threads.index');
Route::get('/threads/{thread}', 'threadsController@show')->name('threads.show');
Route::get('/threads/create', 'threadsController@create')->name('threads.create');
Route::post('/threads', 'threadsController@store')->name('threads.store');
Route::get('/threads/{thread}/edit', 'threadsController@edit')->name('threads.edit');
Route::patch('/threads/{thread}', 'threadsController@update')->name('threads.update');
Route::delete('/threads/{thread}', 'threadsController@destroy')->name('threads.destroy');
 * */

Auth::routes();
Route::get('threads', 'ThreadsController@index')->name('threads');
Route::resource('threads','ThreadsController',['except'=>['show','store','index','destroy']]);
Route::get('threads/{channel}/{thread}','ThreadsController@show')->name('threads.show');
Route::delete('threads/{channel}/{thread}','ThreadsController@destroy')->name('threads.destroy');
Route::get('threads/{channel?}','ThreadsController@index')->name('threads.index');
//邮件验证中间件
Route::post('threads','ThreadsController@store')->middleware('must-be-confirmed');

//Route::get("threads/by=".auth()->user()->name ,'ThreadsController@index')->name('threads.user');



//Route::get('/home', 'HomeController@index')->name('home');
Route::post('/threads/{channel}/{thread}/replies','RepliesController@store');
Route::get('/threads/{channel}/{thread}/replies','RepliesController@index');
//Route::post('/threads/{channel}/{thread}/replies','RepliesController@store');

Route::get('/profiles/{user}','ProfilesController@show')->name('profile');
Route::get('/profiles/{user}/notifications','UserNotificationsController@index');
Route::delete('/profiles/{user}/notifications/{notification}','UserNotificationsController@destroy');

Route::delete('/replies/{reply}','RepliesController@destroy');
Route::patch('/replies/{reply}','RepliesController@update');
Route::delete('/replies/{reply}','RepliesController@destroy');



Route::post('/replies/{reply}/favorites','FavoritesController@store');
Route::delete('/replies/{reply}/favorites','FavoritesController@destroy');


Route::post('/threads/{channel}/{thread}/subscriptions','ThreadSubscriptionsController@store')->middleware('auth');
Route::delete('/threads/{channel}/{thread}/subscriptions','ThreadSubscriptionsController@destroy')->middleware('auth');

//获取被 @ 用户
Route::get('api/users','Api\UsersController@index');
//用户上传
Route::post('api/users/{user}/avatar','Api\UserAvatarController@store')->middleware('auth')->name('avatar');

//Route::get('/register/confirm','Api\RegisterConfirmationController@index');
Route::get('/register/confirm','Auth\RegisterConfirmationController@index')->name('register.confirm');
Route::get('api/users','Api\UsersController@index');
Route::post('api/users/{user}/avatar','Api\UserAvatarController@store')->middleware('auth')->name('avatar');
